﻿<!DOCTYPE html>
<html>
<head>
  <title>付费测</title>

</head>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  <style>
    .g-main{
      margin: 0 auto;
      padding-top: 20px;
      width: 78%;
      margin-bottom: 200px;
    }
    .m-text{
      width: 90%;
      font-size: 16px;
      line-height: 20px;
      padding: 5%;
      margin-bottom: 30px;
      color: white;
      border-radius: 10px;
      background-color: #6495ED;
      position: relative;
    }
  
    .info{
      width: 200px;
      height: 200px;
      background-color: black;
      margin: 0 auto;

    }
    .button{
      display: block;
      margin: 0 auto;
      border:0;
      width: 80%;
      height: 50px;
      line-height: 50px;
      text-align: center;
      border-radius: 5px;
      text-decoration:none;
      color: white;
      font-size: 18px;
      background: linear-gradient(to right, #4f77d0 , #3fa2ca);
      background: -webkit-linear-gradient(to right, #4f77d0 , #3fa2ca);
      background: -o-linear-linear-gradient(to right, #4f77d0 , #3fa2ca);
      background: -moz-linear-linear-gradient(to right, #4f77d0 , #3fa2ca);

    }
    .test{position: absolute;left: 25px;bottom:-20px;width:0; height:0; border-width:10px 10px; border-style:solid; border-color:#6495ED #6495ED #ffffff #ffffff;}
    .test-right{position: absolute;right: 25px;bottom:-20px;width:0; height:0; border-width:10px 10px; border-style:solid; border-color:#6495ED #ffffff #ffffff #6495ED ;}
    .dis{
      width: 100%;
      text-align: center;

    }
    .margin-10{
      margin-bottom: 10px;
    }
    .margin-30{
      margin-bottom: 30px;
    }
    .margin-40{
      margin-bottom: 40px;
    }
    .c-black{
      color: black;
    }
    .xuanfu{
    	width: 95%;
    	 padding: 25px 0;
    	 position: fixed;
    	 bottom: 0;
    	 background-color: white;
    }

  </style>
<body>
    <div class="g-main">
        <div class="m-text">我什么时候才能结束单身？今年桃花运怎么样？什么样的另一半才适合我？什么时候结婚比较合适？怎么调旺我的感情运？
        <!-- <div class="test"></div> -->
        </div>
        <div class="m-text">我今年财运好不好？今年适合投资哪些行业？怎么才能把我的财运调旺？
        	<!-- <div class="test-right"></div> -->
        </div>
        <img class="icon" src="image/icon_button.png" alt="">
        <div class="m-text">这些问题时刻伴随着我们
        	<!-- <div class="test"></div> -->
        </div>
        <div class="m-text margin-40"> 现在需要花费198元，国内知名命理大师就可以帮你解决所有疑惑
        	<!-- <div class="test-right"></div> -->
        </div>
        <div class="dis">
        <img class="info margin-30" src="http://otooldst4.bkt.clouddn.com/E3201C76-F4EC-4CAD-B8EC-962F7970CEE8-215-00000005DE563FE9_tmp.jpg" alt="">
        </div>
        <div class="m-text">孙老师擅长事业财运分析，本身商界人士，结合国学精粹与经验给予全方面指点参考。师承父亲学医学易，幼时刻苦研习学问，大学期间师承武汉台商学会吴会长学易，目前已有三十余年。在十余年的咨询服务生涯中，通过整理测过的用户案例，一步步完善自身理论，由量变到质变，拥有一套准确度极高的理论体系。希望用专业知识能帮助更多的人更好了解自我，更好规划人生！
        </div>
        
    </div>
    <div class="xuanfu">
        	<button class="button" id="button1" >
          支付 ¥198.00
        </button>
        </div>
</body>
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var appId = '';
var timeStamp = '';
var nonceStr = '';
var pg = '';
var signType = '';
var paySign = '';
var data = {total_fee:19800,body:"算的准-运势"}

console.log(data)
// openId:openId,
// var body='算的准-运势';
// var openId='o8ocgxKik19v4hgt3KdOfEDuX0eg';
// console.log(body);
// console.log(openId)
	document.getElementById("button1").onclick=function(){
		$.ajax({  
                
                type: 'POST',   
                dataType: 'json',
                async:false,
                url: '/wxmp/pay',  
                data:JSON.stringify(data),
                headers:{
                	'Content-type':'application/json'
                },
                success: function(msg){  
                      
                    if(msg!=null){  
                        appId = msg.appId;  
                        timeStamp = msg.timeStamp;    
                        nonceStr = msg.nonceStr;  
                        pg = msg.package;  
                        signType = msg.signType;   
                        paySign = msg.paySign;  
                    }  
                    pay(); 
                }  
            });  


function pay(){    
    if (typeof WeixinJSBridge == "undefined"){    
       if( document.addEventListener ){    
           document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);    
       }else if (document.attachEvent){    
           document.attachEvent('WeixinJSBridgeReady', onBridgeReady);     
           document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);    
       }    
    }else{    
       onBridgeReady();    
    }     
        
}    
function onBridgeReady(){    
    WeixinJSBridge.invoke(    
        'getBrandWCPayRequest', {    
            "appId" : appId,     //公众号名称，由商户传入         
            "timeStamp": timeStamp,         //时间戳，自1970年以来的秒数         
            "nonceStr" : nonceStr, //随机串         
            "package" : pg,         
            "signType" : signType,         //微信签名方式:         
            "paySign" : paySign    //微信签名     
        },    
            
        function(res){         
            if(res.err_msg == "get_brand_wcpay_request:ok" ) {    
                alert("支付成功");  // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回    ok，但并不保证它绝对可靠。     
                //回到用户订单列表  
                window.location.href="wx_payment_next.html";  
            }else if (res.err_msg == "get_brand_wcpay_request:cancel")  {  
                alert("支付过程中用户取消");  
            }else{  
               //支付失败  
               alert(res.err_msg)  
            }       
        }    
    );     
 }   
};
</script>
</html>